package com.ld.control.business.record.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ld.control.business.record.service.MessageNoticeRecordService;
import com.ld.control.business.record.vo.req.ReadAlreadyReqVo;
import com.ld.control.business.record.vo.resp.ErrorNoticeRecordRespVo;
import com.ld.control.business.record.vo.resp.MessageNoticeRecordRespVo;
import com.ld.control.business.record.vo.resp.NoticeTipRespVo;
import com.ld.control.common.ResultResponse;
import com.ld.control.common.vo.GeneratePageListVo;
import com.ld.control.sysenum.ResultResponseEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 任务报错后的记录和处理 前端控制器
 * </p>
 *
 * @author wangfeng
 * @since 2024-07-15
 */
@Slf4j
@Tag(name = "消息通知相关接口")
@RestController
public class MessageNoticeRecordController {


    @Autowired
    private MessageNoticeRecordService messageNoticeRecordService;


    @GetMapping("/api/centralControl/messageNoticeRecord/getPageList")
    @Operation(summary = "消息通知列表")
    public ResultResponse<GeneratePageListVo<MessageNoticeRecordRespVo>> getPageList(
            @Parameter(description = "状态：0未读，1已读") @RequestParam(required = false) Integer status,
            @Parameter(description = "0普通消息，1告警消息") @RequestParam(required = false) Integer type,
            @RequestParam(required = false, defaultValue = "1") Integer current,
            @RequestParam(required = false, defaultValue = "10") Integer size
    ) {
        GeneratePageListVo<MessageNoticeRecordRespVo> respVoGeneratePageListVo = messageNoticeRecordService.getPageList(status, type, current, size);
        return ResultResponse.success(respVoGeneratePageListVo);
    }

    @PostMapping("/api/centralControl/messageNoticeRecord/readAlready")
    @Operation(summary = "已读接口")
    public ResultResponse<ResultResponseEnum> readAlready(
            @RequestBody ReadAlreadyReqVo readAlready
    ){
        messageNoticeRecordService.readAlready(readAlready);
        return ResultResponse.success();
    }

    @PostMapping("/api/centralControl/messageNoticeRecord/allReadAlready")
    @Operation(summary = "全部已读")
    public ResultResponse<ResultResponseEnum> allReadAlready(
    ){
        messageNoticeRecordService.readAlready(null);
        return ResultResponse.success();
    }

    @GetMapping("/api/centralControl/messageNoticeRecord/getNoticeTipInfo")
    @Operation(summary = "小铃铛消息")
    public ResultResponse<NoticeTipRespVo> getNoticeTipInfo(
    ){
        NoticeTipRespVo noticeTipInfo = messageNoticeRecordService.getNoticeTipInfo();
        return ResultResponse.success(noticeTipInfo);
    }





}

